package com.pubinfo.passbook.common.model.vo.base;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pubinfo.passbook.common.model.dto.system.PageParamBase;
import com.pubinfo.passbook.common.model.dto.tax.InvoicePageParamObj;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
@ApiModel(value = "分页数据")
public class MyPage<T> extends Page<T> implements Serializable {
  
  private static final long serialVersionUID = -7770484662988510394L;
  @ApiModelProperty(value = "总页数")
  private Long countPage = 0L;//d
  @ApiModelProperty(value = "当前页")
  private Long currentPage = 1L;
  @ApiModelProperty(value = "总条数")
  private Long totalItem = 0L;
  @ApiModelProperty(value = "当前页行数")
  private Long itemsPerPage = 10L;
  @ApiModelProperty(value = "返回集合数据")
  private List<T> data;
  
  public MyPage(InvoicePageParamObj paramObj) {
    this.currentPage = paramObj.getCurrent();
    this.itemsPerPage = paramObj.getSize();
  }
  
  public MyPage(PageParamBase paramObj) {
    this.currentPage = paramObj.getCurrent();
    this.itemsPerPage = paramObj.getSize();
  }
  
  public MyPage(MyPage iPage) {
    this.data = iPage.getRecords();
    this.totalItem = iPage.getTotal();
    this.currentPage = iPage.getCurrent();
    this.itemsPerPage = iPage.getSize();
    this.countPage = iPage.getPages();
  }
  
  public MyPage(IPage iPage) {
    this.data = iPage.getRecords();
    this.totalItem = iPage.getTotal();
    this.currentPage = iPage.getCurrent();
    this.itemsPerPage = iPage.getSize();
    this.countPage = iPage.getPages();
  }
  
  public MyPage() {
  
  }
}
